# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=polyphone
pkgver=2.3.0
pkgrel=3
pkgdesc="A soundfont editor for quickly designing musical instruments"
arch=(loong64 x86_64)
url="https://polyphone-soundfonts.com/en/"
license=(GPL3)
groups=(pro-audio)
depends=(gcc-libs glibc hicolor-icon-theme openssl qt5-base qt5-svg zlib)
makedepends=(flac jack libogg libvorbis portaudio rtmidi qcustomplot qt5-tools stk)
options=(debug)
source=($pkgname-$pkgver.tar.gz::https://github.com/davy7125/$pkgname/archive/$pkgver.tar.gz)
sha512sums=('4179201716f08e1815863b4a5c2950f53faebd82eaf8d92f8e8d4b991caac1733a52e19abcfd278c3466ecb5eea35acfd8f2fe8d7bb27981992bb5593df9469e')
b2sums=('92eee8583a3ac97b7c4ae39777a3ecf5c01c2c44ea34d653fe3f6b9b65f92c805712b56566822c473415cbd641b21d4689e780efeaf232ce3de18695d88d92d7')

build() {
  cd $pkgname-$pkgver/sources
  qmake-qt5 $pkgname.pro PREFIX=/usr
  make
}

package() {
  depends+=(libFLAC.so libjack.so libogg.so libportaudio.so
  libqcustomplot.so libstk-4.6.2.so libvorbis.so libvorbisenc.so
  libvorbisfile.so)

  cd $pkgname-$pkgver/sources
  # doesn't have an install target: https://github.com/davy7125/polyphone/issues/62
  install -vDm 755 bin/$pkgname -t "$pkgdir/usr/bin/"
  install -vDm 644 resources/logo.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
  install -vDm 644 resources/$pkgname.png -t "$pkgdir/usr/share/icons/hicolor/512x512/apps"
  install -vDm 644 contrib/man/fr/man1/$pkgname.*1 -t "$pkgdir/usr/share/man/fr/man1/"
  install -vDm 644 contrib/man/man1/$pkgname.*1 -t "$pkgdir/usr/share/man/man1/"
  install -vDm 644 contrib/man/ru/man1/$pkgname.*1 -t "$pkgdir/usr/share/man/ru/man1/"
  install -vDm 644 contrib/*.desktop -t "$pkgdir/usr/share/applications/"
  install -vDm 644 contrib/audio-x-soundfont.svg -t "$pkgdir/usr/share/icons/hicolor/scalable/mimetypes/"
  install -vDm 644 contrib/*.xml -t "$pkgdir/usr/share/metainfo/"
  install -vDm 644 contrib/$pkgname.xml -t "$pkgdir/usr/share/mime/packages/"
  install -vDm 644 {../README.md,changelog} -t "$pkgdir/usr/share/doc/$pkgname/"
}
